//
//  LHHotelDetailViewController.m
//  Knight_Tour
//
//  Created by dlios on 15-5-15.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHHotelDetailViewController.h"
#import "LHHotelDetailUserView.h"
#import "MyNavgationView.h"
#import "LHRecommendHotelDetailViewController.h"
@interface LHHotelDetailViewController ()<JumpToHotelDetailDelegate>
@property (nonatomic ,retain) NSMutableArray *hotelDetailArr;
@property (nonatomic ,retain) LHHotelDetailUserView *HDUV;
@end

@implementation LHHotelDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationController.navigationBar.hidden = YES;
    [self setAutomaticallyAdjustsScrollViewInsets:NO];
    [self getManagerWithCover];
    [self createTableView];
    [self createNavigation];
}
- (void) createTableView
{
    self.HDUV = [[LHHotelDetailUserView alloc] initWithFrame:CGRectMake(0, 64, LHWidth, LHheight - 64)];
    _HDUV.modelArr = self.hotelDetailArr;
    self.HDUV.delegate = self;
    [self.view addSubview:_HDUV];
    [_HDUV release];
}
- (void)createNavigation
{
    MyNavgationView *myNV = [[MyNavgationView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
    
    self.navigationController.navigationBar.translucent = NO;
    myNV.leftTarget = self;
    myNV.leftAction = @selector(backToUser);
    [myNV creatLeftButtonWithImage:@"btn_nav_back"];
    
    [myNV creatTitle:@"我的旅店"];
    [self.view addSubview:myNV];
    [myNV release];
}

- (void)backToUser
{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void) getManagerWithCover
{
    NSString *path = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"LHRecommendHotel"] stringByAppendingPathComponent:@"LHRecommendHotel.kk"];
    self.hotelDetailArr = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
}

- (void)jumpToHotelDetail:(NSIndexPath *)index
{
    LHRecommendHotelDetailViewController *RHDVC = [[LHRecommendHotelDetailViewController alloc] init];
    RHDVC.hotelModel = self.hotelDetailArr[index.row];
    [RHDVC setHidesBottomBarWhenPushed:NO];
    [self.navigationController pushViewController:RHDVC animated:YES];
    [RHDVC release];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
